Stata
* Substrings
replace cm_name = substr(cm_name,1, length(cm_name)-9)
* Check type of variable
describe var1
* Create variable identifier /ID Variable by group, two ways to do it:
encode locations, gen(locationsn)
egen locationsn = group(locations)
* if "something" then continue, in this case: if dataset is empty, then continue
count
if `r(N)' ==0{
restore
continue
}
* Creating missing values
replace log_dif_km ="" if log_dif_km=="-Inf"| log_dif_km=="Inf" | log_dif_km=="NA"
* Transform string to numeric
gen double read_n = real(read)